package com.blink.optimize.apis.switchs;

import org.junit.jupiter.api.Test;

/**
 * <ClassName>TestSwitch</ClassName>
 * <Description></Description>
 *
 * @Author liuxianzhao
 * @Date 2018年01月06日 18:15
 */
public class TestSwitch {
    @Test
    public void testSwitch() {
        //switch(A),括号中A的取值可以是byte、short、int、char、String，还有枚举类型，应用举例：
        //(1)byte
        byte baction = 2;
        switch (baction) {
            case 1:
                System.out.print(baction);
                break;
            case 2:
                System.out.print(baction);
                break;
        }
        //(2)short
        short saction = 3;
        switch (saction) {
            case 1:
                System.out.print(saction);
                break;
            case 3:
                System.out.print(saction);
                break;
        }
        //(3)int
        int iaction = 4;
        switch (iaction) {
            case 1:
                System.out.print(iaction);
                break;
            case 4:
                System.out.print(iaction);
                break;
        }
        //(4)char
        char caction = 'a';
        switch (caction) {
            case 1:
                System.out.print(caction);
                break;
            case 'a':
                System.out.print(caction);
                break;
        }
        //(5)String
        String straction = "abc";
        switch (straction) {
            case "1":
                System.out.print(straction);
                break;
            case "abc":
                System.out.print(straction);
                break;
        }
        //(6)枚举
        String fullStr = "00000000000000";
        CompletedProgressEnum action = CompletedProgressEnum.basic;
        StringBuilder sb = new StringBuilder(fullStr);
        switch (action) {
            case basic:
                sb.replace(0, 2, CompletedProgressEnum.basic.getValue());
                break;
            case edu:
                sb.replace(2, 4, CompletedProgressEnum.edu.getValue());
                break;
        }
    }
}
